/* access mysql database through JDBC Driver */ 
package dreampack;

import java.sql.*;

//import javax.naming.*;
//import javax.sql.*;
//import java.util.*;

public class DreamDB {
	/*private String dbUrl = "jdbc:mysql://localhost:3306/class1_1?useUnicode=true";
	private String dbUser = "caifeifei";
	private String dbPwd = "112997";*/
	
	public DreamDB() throws Exception{
		//Class.forName("com.mysql.jdbc.Driver");
		Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
	}
	
	public Connection getConnection() throws Exception{
		//return DriverManager.getConnection(dbUrl, dbUser, dbPwd);
		return DriverManager.getConnection("proxool.Dream");
	}
	
	public void closeConnection(Connection con){
		try{
			if (null != con) con.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void closePrepStmt(PreparedStatement prepStmt){
		try{
			if (null != prepStmt) prepStmt.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void closeStatement(Statement stmt){
		try{
			if (null != stmt) stmt.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void closeResultSet(ResultSet rs){
		try{
			if (null != rs) rs.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
